package com.gusha.app;

import java.math.BigInteger;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gusha.dao.SysReportDao;
import com.gusha.model.SysReport;
import com.gusha.utils.JsonResult;

@CrossOrigin(origins="*",maxAge=3600)
@Controller
@RequestMapping("/app/report")
public class AppReportController {
	@Autowired
	private SysReportDao sysReportDao;
	
	
	//发起举报
	@CrossOrigin(origins="*",maxAge=3600)
	@RequestMapping("/toReport")
	@ResponseBody
	public JsonResult toReport(SysReport report,HttpServletRequest request) {
		JsonResult result=new JsonResult(false);
		if(report.getUser()!=null&&report.getContentType()!=null) {
			Date date=new Date();
			report.setReportTime(date);
			report.setIsCheck(new BigInteger("0"));
			sysReportDao.saveAndFlush(report);
			result.setMsg("操作成功");
			result.setFlag(true);
			return result;
		}
		return result;
		
	}
}
